#!/usr/bin/env bash
curl -XPOST y1:9200/wechat_biz/fulltext/_search?pretty -d '
{"query":
	{
                    "must": {
                        "bool": {
                            "should": [
                                {
                                    "match": {
                                        "biz_name": {
                                            "query": "人民",
                                            "minimum_should_match": "5<85% 10<9"
                                        }
                                    }
                                },
                                {
                                    "match": {
                                        "biz_code": {
                                            "query": "人民",
                                            "minimum_should_match": "5<85% 10<9"
                                        }
                                    }
                                },
                                {
                                    "match": {
                                        "biz_info": {
                                            "query": "人民",
                                            "minimum_should_match": "5<85% 10<9"
                                        }
                                    }
                                },
                                {
                                    "multi_match": {
                                        "query": "人民",
                                        "type": "cross_fields",
                                        "fields": ["biz_name", "biz_info", "keywords"],
                                        "minimum_should_match": "5<85% 10<9"
                                    }
                                }
                            ]
                        }
                    }
    }
}'



curl -XPOST y1:9200/wechat_biz/fulltext/_search?pretty -d '
{
  "_source": ["biz_name", "biz_code", "biz_info"],
  "query" : {
 "multi_match" : {
 "fields":["keywords"],
 "query_string" : "女装 大码"
 }},
"size": 100

}'


curl -XPOST y1:9200/wechat_biz/fulltext/_search?pretty -d '
{
  "_source": ["biz_name", "biz_code", "biz_info"],
  "query" : {
 "query_string" : {
 "fields": ["keywords"],
 "query" : "女装 伊思君凯 青亦 恤女 恤潮 加肥 欧芮儿"
 }},
"size": 100,
"highlight": {"fields": {"keywords": {}}}

}'


curl -XPOST y1:9200/wechat_biz/fulltext/_search?pretty -d '
{"query":
	{

                        "bool": {
                            "should": [
                                {
                                    "match": {
                                        "biz_name": {
                                            "query": "女装 伊思君凯 青亦 恤女 恤潮 加肥 欧芮儿",
                                            "minimum_should_match": "5<85% 10<9"
                                        }
                                    }
                                },
                                {
                                    "match": {
                                        "biz_info": {
                                            "query": "女装 伊思君凯 青亦 恤女 恤潮 加肥 欧芮儿",
                                            "minimum_should_match": "5<85% 10<9"
                                        }
                                    }
                                },
                                {
                                    "query_string": {
                                        "query": "女装 伊思君凯 青亦 恤女 恤潮 加肥 欧芮儿",
                                        "fields": ["keywords", "biz_name", "biz_info"],
                                        "minimum_should_match": "5<85% 10<9"
                                    }
                                }
                            ]
                        }

    }
}'


curl -XPOST y1:9200/wechat_article/fulltext/_search?pretty -d '
{
 "query" : {
  "bool":{"filter":[]}
 },
 "sort" : {
  "_script" : {
   "script" : {"lang": "painless", "inline": "if (doc.read_num.value == 0 or doc.like_num.value >= doc.read_num.value) {return 0} else {return doc.like_num.value/doc.read_num.value}" },
   "type" : "number",
   "order" : "desc"
  }
 }
}'
